package com.ruoyi.web.controller.inv;

import com.ruoyi.buy.domain.entity.PO.InvArriveInfoItem;
import com.ruoyi.buy.domain.entity.inv0011.Inv0011Data;
import com.ruoyi.buy.domain.entity.inv0012.Inv0012Data;
import com.ruoyi.buy.domain.entity.inv0014.Inv0014Data;
import com.ruoyi.buy.service.IInvArriveInfoItemService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 到货单明细Controller
 * 
 * @author ruoyi
 * @date 2024-04-29
 */
@RestController
@RequestMapping("/inv/ArriveInfoitem")
public class InvArriveInfoItemController extends BaseController
{
    @Autowired
    private IInvArriveInfoItemService invArriveInfoItemService;

    @GetMapping("/list")
    public TableDataInfo list(Inv0011Data invArriveInfoItem)
    {
        startPage();
        List<Inv0011Data> list = invArriveInfoItemService.selectNotArrivedItem(invArriveInfoItem);
        return getDataTable(list);
    }

//    /**
//     * 导出到货单明细列表
//     */
//    @Log(title = "到货单明细", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, InvArriveInfoItem invArriveInfoItem)
//    {
//        List<InvArriveInfoItem> list = invArriveInfoItemService.selectInvArriveInfoItemList(invArriveInfoItem);
//        ExcelUtil<InvArriveInfoItem> util = new ExcelUtil<InvArriveInfoItem>(InvArriveInfoItem.class);
//        util.exportExcel(response, list, "到货单明细数据");
//    }

    /**
     * 获取到货单明细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(invArriveInfoItemService.selectInvArriveInfoItemById(id));
    }

    /**
     * 新增到货单明细
     */
    @Log(title = "到货单明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody InvArriveInfoItem invArriveInfoItem)
    {
        return toAjax(invArriveInfoItemService.insertInvArriveInfoItem(invArriveInfoItem));
    }

    /**
     * 修改到货单明细
     */
    @Log(title = "到货单明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody InvArriveInfoItem invArriveInfoItem)
    {
        return toAjax(invArriveInfoItemService.updateInvArriveInfoItem(invArriveInfoItem));
    }

    /**
     * 删除到货单明细
     */
    @Log(title = "到货单明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(invArriveInfoItemService.deleteInvArriveInfoItemByIds(ids));
    }

    /**
     * 新增到货单明细
     */
    @PostMapping("/insertInvArriveInfoItem")
    public AjaxResult insertInvArriveInfoItem(@RequestBody List<Inv0011Data> invArriveInfoItems) throws Exception {
        return toAjax(invArriveInfoItemService.arriveConfirm(invArriveInfoItems));
    }

    @GetMapping("/selectNotInWHInfoList")
    public TableDataInfo list(Inv0012Data inv0012Data)
    {
        startPage();
        List<Inv0012Data> list = invArriveInfoItemService.selectNotInWHInfoList(inv0012Data);
        return getDataTable(list);
    }

    /**
     * 执行入库
     */
    @PostMapping("/executeIn")
    public AjaxResult executeIn(@RequestBody List<Inv0012Data> list) throws Exception {
        return toAjax(invArriveInfoItemService.executeIn(list));
    }

    /**
     * 查询到货单明细列表
     */
    @GetMapping("/searchList")
    public TableDataInfo searchList(InvArriveInfoItem invArriveInfoItem)
    {
        startPage();
        List<InvArriveInfoItem> list = invArriveInfoItemService.selectInvArriveInfoItemList(invArriveInfoItem);
        return getDataTable(list);
    }

    /**
     * 查询到货单明细列表
     */
    @GetMapping("/searchInList")
    public TableDataInfo searchInList(Inv0014Data param)
    {
        startPage();
        List<Inv0014Data> list = invArriveInfoItemService.searchInList(param);
        return getDataTable(list);
    }


}
